package com.szxy.content.service.impl;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.netflix.discovery.converters.Auto;
import com.szxy.content.service.ContentCategoryService;
import com.szxy.mapper.TbContentCategoryMapper;
import com.szxy.pojo.TbContentCategory;
import com.szxy.pojo.TbContentCategoryExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther:zwer
 * @Date:2019/9/9 21:23
 * @Description:com.szxy.content.service
 * @Version:1.0
 **/
@Service
public class ContentCategoryServiceImpl implements ContentCategoryService {

    @Autowired
    private TbContentCategoryMapper contentCategoryMapper;

    @Override
    @LcnTransaction
    public Integer updateContentCategoryById(TbContentCategory tbContentCategory) {
        return this.contentCategoryMapper.updateByPrimaryKeySelective(tbContentCategory);
    }

    @Override
    public List<TbContentCategory> selectContentCategoryByParentId(Long id) {
        TbContentCategoryExample example = new TbContentCategoryExample();
        TbContentCategoryExample.Criteria criteria = example.createCriteria();
        criteria.andStatusEqualTo(1);
        criteria.andParentIdEqualTo(id);
        return this.contentCategoryMapper.selectByExample(example);
    }

    @Override
    @LcnTransaction
    public Integer deleteContentCategoryById(Long categoryId) {
        return this.contentCategoryMapper.deleteByPrimaryKey(categoryId);
    }

    @Override
    @LcnTransaction
    public int insertContentCategory(TbContentCategory contentCategory) {
        return this.contentCategoryMapper.insert(contentCategory);
    }

}

